package day20170420.hashmap;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

import org.junit.Test;

public class HashMapTest {
	/**
	 * 初始化学生对象
	 */
	private Student student;
	
	/**
	 * Map中装list测试
	 * @throws Exception
	 */
	@Test
	public void hashMapTest() throws Exception {
		
		//第一组
		List<Student> one = new ArrayList<Student>();
		student = new Student();
		student.setName("曾少华");
		one.add(student);
		
		student = new Student();
		student.setName("贾梦菊");
		one.add(student);
		
		//第二组
		List<Student> two = new ArrayList<Student>();
		student = new Student();
		student.setName("靳志辉");
		two.add(student);
		
		student = new Student();
		student.setName("周驰");
		two.add(student);
		
		//第三组
		List<Student> three = new ArrayList<Student>();
		student = new Student();
		student.setName("罗智壕");
		three.add(student);
		
		student = new Student();
		student.setName("张嘉源");
		three.add(student);
		
		student = new Student();
		student.setName("何小强");
		three.add(student);
		
		
		
		//装进map
		Map<String, List<Student>> class1704 = new HashMap<String, List<Student>>();
		class1704.put("贾梦菊", one);
		class1704.put("靳志辉", two);
		class1704.put("罗智壕", three);
		 
		//初始化扫描仪
		Scanner scanner = new Scanner(System.in);
		System.out.println("输入需要查询的组长名字：");
		//拿到输入的名字
		String name = scanner.next();
		
		//查询
		System.out.println(class1704.get(name));
		
		//关闭
		scanner.close();
	}
}
